package com.xxx.video.commen.views;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.xxx.video.R;
import com.xxx.video.commen.utils.StringUtils;
import com.xxx.video.commen.utils.ToastUtils;

import butterknife.BindView;
import butterknife.OnClick;

public class AddFriendExtraMessageDialog extends BaseDialog {

    @BindView(R.id.tv_add_friend_extra_message_title)
    TextView tvAddFriendExtraMessageTitle;
    @BindView(R.id.et_add_friend_extra_message)
    EditText etAddFriendExtraMessage;
    @BindView(R.id.tv_add_friend_extra_message_cancel)
    TextView tvAddFriendExtraMessageCancel;
    @BindView(R.id.tv_add_friend_extra_message_confrim)
    TextView tvAddFriendExtraMessageConfrim;
    private OnButtonClickListener onButtonClickListener;

    public AddFriendExtraMessageDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    public int getContentLayout() {
        return R.layout.dialog_add_friend_extra_message;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initView(View view) {

    }

    public interface OnButtonClickListener {
        /**
         * on confirm click
         *
         * @param message message
         */
        void onConfirmClick(String message);
    }

    public void setOnButtonClickListener(OnButtonClickListener onButtonClickListener) {
        this.onButtonClickListener = onButtonClickListener;
    }

    @OnClick({R.id.tv_add_friend_extra_message_cancel, R.id.tv_add_friend_extra_message_confrim})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_add_friend_extra_message_cancel:
                dismiss();
                break;
            case R.id.tv_add_friend_extra_message_confrim:
                if (TextUtils.isEmpty(getMessage())){
                    ToastUtils.showError(StringUtils.getInstance().getString(R.string.tip_please_input_message));
                    return;
                }
                if (onButtonClickListener != null) {
                    onButtonClickListener.onConfirmClick(getMessage());
                }
                dismiss();
                break;
            default:
                break;
        }
    }

    public String getMessage() {
        return etAddFriendExtraMessage.getText().toString().trim();
    }
}
